#!/bin/bash
# Copyright (c) 2025 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ARK_VERSION=15.0.4-0d8b9c-ark
LLVM_ARK_VERSION=llvm-15.0.4-ark18

curl -Lo /opt/${LLVM_ARK_VERSION:?}-release-ohos.tar.xz  https://repo.huaweicloud.com/harmonyos/compiler/clang/${ARK_VERSION:?}/${LLVM_ARK_VERSION:?}-release-ohos.tar.xz && \
mkdir -p /opt/llvm-15-release-ohos && \
curl -Lo /opt/${LLVM_ARK_VERSION:?}-release-x86_64.tar.xz -q https://repo.huaweicloud.com/harmonyos/compiler/clang/${ARK_VERSION:?}/${LLVM_ARK_VERSION:?}-release-x86_64.tar.xz && \
mkdir -p /opt/llvm-15-release-x86_64 && \
curl -Lo /opt/${LLVM_ARK_VERSION:?}-release-aarch64.tar.xz -q https://repo.huaweicloud.com/harmonyos/compiler/clang/${ARK_VERSION:?}/${LLVM_ARK_VERSION:?}-release-aarch64.tar.xz && \
mkdir -p /opt/llvm-15-release-aarch64 && \
curl -Lo /opt/${LLVM_ARK_VERSION:?}-debug-aarch64.tar.xz -q https://repo.huaweicloud.com/harmonyos/compiler/clang/${ARK_VERSION:?}/${LLVM_ARK_VERSION:?}-debug-aarch64.tar.xz && \
mkdir -p /opt/llvm-15-debug-aarch64 && \
curl -Lo /opt/${LLVM_ARK_VERSION:?}-debug-x86_64.tar.xz -q https://repo.huaweicloud.com/harmonyos/compiler/clang/${ARK_VERSION:?}/${LLVM_ARK_VERSION:?}-debug-x86_64.tar.xz && \
mkdir -p /opt/llvm-15-debug-x86_64 && \
tar -xJf /opt/${LLVM_ARK_VERSION:?}-release-ohos.tar.xz -C /opt/llvm-15-release-ohos && \
tar -xJf /opt/${LLVM_ARK_VERSION:?}-release-x86_64.tar.xz -C /opt/llvm-15-release-x86_64 && \
tar -xJf /opt/${LLVM_ARK_VERSION:?}-release-aarch64.tar.xz -C /opt/llvm-15-release-aarch64 && \
tar -xJf /opt/${LLVM_ARK_VERSION:?}-debug-x86_64.tar.xz -C /opt/llvm-15-debug-x86_64 && \
tar -xJf /opt/${LLVM_ARK_VERSION:?}-debug-aarch64.tar.xz -C /opt/llvm-15-debug-aarch64 && \
rm -fr /opt/${LLVM_ARK_VERSION:?}*
